import {
  Controller,
  Get,
  Post,
  Param,
  Delete,
  Query,
  Body,
} from '@nestjs/common';
import { BlogCategoryService } from './blog_category.service';
import { CreateBlogCategoryDto } from './dto/create-blog_category.dto';
import { UpdateBlogCategoryDto } from './dto/update-blog_category.dto';

@Controller('blogCategory')
export class BlogCategoryController {
  constructor(private readonly blogCategoryService: BlogCategoryService) {}

  @Post('create')
  async createCategory(@Body() createBlogCategoryDto: CreateBlogCategoryDto) {
    return await this.blogCategoryService.createCategory(createBlogCategoryDto)
  }

  @Get('list')
  async getAllCategory() {
    return await this.blogCategoryService.findAll()
  }

  @Get('getCategoryById')
  async getCategoryById(@Query('id') id: number) {
    return await this.blogCategoryService.findOneById(id)
  }

  @Post('update')
  async updateCategory(@Body() updateBlogCategoryDto:UpdateBlogCategoryDto) {
    return await this.blogCategoryService.update(updateBlogCategoryDto)
  }

  @Delete('removeById/:id')
  async removeCategory(@Param() id: number) {
    return await this.blogCategoryService.removeById(id);
  }
}
